# zip()
from functools import reduce

var1 = [1, 2, 3, 4]
var2 = ["a", "b", "c", "d"]
var3 = ["A", "B", "C", "D"]
res_01 = zip(var1, var2, var3)
print(res_01, type(res_01))
for i in res_01:
    print(i)
x = [1, 2, 3]
y = [4, 5, 6]
res_02 = zip(x, y)
print(list(res_02))
x1, y1 = zip(*zip(x, y))
print(x1, y1)
# sorted()
arr_01 = [1, 27, 38, 47, 54, 664, 7, 8, 9]
res_03 = sorted(arr_01)
print(res_03)
res_04 = sorted(arr_01, reverse=True)
print(res_04)
# map()
"""
map(func, iterable)
功能：对传入的可迭代数据中的每一个元素进行func处理，返回一个新的迭代器
parameter: 
        func: processing 
        iterables: iterable objects
return: iterator
"""
list_01 = ["1", "2", "3", "4"]
res_05 = map(int, list_01)
print(list(res_05))

list_02 = [1, 2, 3, 4]
res_06 = map(lambda x: x ** 2, list_02)
print(list(res_06))

"""
reduce(func, iterable)
"""
list_03 = [5, 2, 1, 1]

res_07 = reduce(lambda x, y: x * 10 + y, list_03)
print(res_07)
"""
filter(func, iterable)
"""
list_04 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
res_08 = filter(lambda n: True if n % 2 == 0 else False, list_04)
print(list(res_08))
